package com.ruoyi.knowledge.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.knowledge.domain.QualityDiseasesCatalogueDetail;
import com.ruoyi.knowledge.service.IQualityDiseasesCatalogueDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 常见质量通病目录详情Controller
 * 
 * @author zhaogang
 * @date 2024-07-14
 */
@RestController
@RequestMapping("/knowledge/knowledgeDetail")
public class QualityDiseasesCatalogueDetailController extends BaseController
{
    @Autowired
    private IQualityDiseasesCatalogueDetailService qualityDiseasesCatalogueDetailService;

    /**
     * 查询常见质量通病目录详情列表
     */
    @PreAuthorize("@ss.hasPermi('knowledge:knowledgeDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(QualityDiseasesCatalogueDetail qualityDiseasesCatalogueDetail)
    {
        startPage();
        List<QualityDiseasesCatalogueDetail> list = qualityDiseasesCatalogueDetailService.selectQualityDiseasesCatalogueDetailList(qualityDiseasesCatalogueDetail);
        return getDataTable(list);
    }

    /**
     * 导出常见质量通病目录详情列表
     */
    @PreAuthorize("@ss.hasPermi('knowledge:knowledgeDetail:export')")
    @Log(title = "常见质量通病目录详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QualityDiseasesCatalogueDetail qualityDiseasesCatalogueDetail)
    {
        List<QualityDiseasesCatalogueDetail> list = qualityDiseasesCatalogueDetailService.selectQualityDiseasesCatalogueDetailList(qualityDiseasesCatalogueDetail);
        ExcelUtil<QualityDiseasesCatalogueDetail> util = new ExcelUtil<QualityDiseasesCatalogueDetail>(QualityDiseasesCatalogueDetail.class);
        util.exportExcel(response, list, "常见质量通病目录详情数据");
    }

    /**
     * 获取常见质量通病目录详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('knowledge:knowledgeDetail:query')")
    @GetMapping(value = "/{catalogueDetailId}")
    public AjaxResult getInfo(@PathVariable("catalogueDetailId") Long catalogueDetailId)
    {
        return success(qualityDiseasesCatalogueDetailService.selectQualityDiseasesCatalogueDetailByCatalogueDetailId(catalogueDetailId));
    }

    /**
     * 新增常见质量通病目录详情
     */
    @PreAuthorize("@ss.hasPermi('knowledge:knowledgeDetail:add')")
    @Log(title = "常见质量通病目录详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QualityDiseasesCatalogueDetail qualityDiseasesCatalogueDetail)
    {
        return toAjax(qualityDiseasesCatalogueDetailService.insertQualityDiseasesCatalogueDetail(qualityDiseasesCatalogueDetail));
    }

    /**
     * 修改常见质量通病目录详情
     */
    @PreAuthorize("@ss.hasPermi('knowledge:knowledgeDetail:edit')")
    @Log(title = "常见质量通病目录详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QualityDiseasesCatalogueDetail qualityDiseasesCatalogueDetail)
    {
        return toAjax(qualityDiseasesCatalogueDetailService.updateQualityDiseasesCatalogueDetail(qualityDiseasesCatalogueDetail));
    }

    /**
     * 删除常见质量通病目录详情
     */
    @PreAuthorize("@ss.hasPermi('knowledge:knowledgeDetail:remove')")
    @Log(title = "常见质量通病目录详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{catalogueDetailIds}")
    public AjaxResult remove(@PathVariable Long[] catalogueDetailIds)
    {
        return toAjax(qualityDiseasesCatalogueDetailService.deleteQualityDiseasesCatalogueDetailByCatalogueDetailIds(catalogueDetailIds));
    }
}
